<template>
  <div class="dashboard-container">
    <div class="dashboard-editor-container">
      <!--<yshop-info />-->
      <panel-group />
      <panel-group-t />
    </div>
    <div class="foot">茶叶库存</div>
     <div ref="storechart" id="demo"></div>
  </div>
</template>

<script>
 import PanelGroup from './dashboard/PanelGroup.vue'
 import PanelGroupT from './dashboard/PanelGroupT.vue'
 import PieChart from './dashboard/PieChart.vue'
 import BarChart from './dashboard/BarChartT.vue'
 import OrderCount from './dashboard/OrderCount.vue'
 import * as echarts from "echarts"
 import{teaCount} from '@/api/tea/count'
export default {
  name: "Index",
  components: {
    PanelGroup,
    PanelGroupT,
    PieChart,
    BarChart,
    OrderCount
  },
  data() {
    return {
      // 版本号
      version: "3.8.5",
      storedata:[]
    };
  },
  mounted(){
    let store=[]
    teaCount().then(response => {
      console.log("库",response)
      response.forEach((item)=>{
       store.push(item.teaNum)
      })
    });
    setTimeout(()=>{
      let option = {
        xAxis: {
          data: ['绿茶', '红茶', '黄茶', '乌龙茶', '白茶', '黑茶']
        },
        yAxis: {
          name:"库存",
          axisLabel: {formatter: '{value} g'},
        },
        series: [
          {
            type: 'bar',
            data:store,
            itemStyle: {
              normal: {
                label: {
                  show: true, //开启显示
                  position: 'top', //在上方显示
                  textStyle: { //数值样式
                    color: 'black',
                    fontSize: 16
                  }
                }
            }
          }
        }
        ]
      };
      let myEcharts=echarts.init(this.$refs.storechart)
      myEcharts.setOption(option)
    },2000)

  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 18px 22px 22px 22px;
    background-color: rgb(240, 242, 245);

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }
  .foot{
        text-align: center;
        font-size: 24px;
        color: gray;
        padding: 20px 0;
  }
  #demo{
    width: 100%;
    height: 500px;
  }
</style>
